/**
 * Created by Administrator on 2017/3/16 0016.
 */
MusicControl={
    Create:function(getArr){
        var mc={};
        var arr=[];
        var currentIdx=0;
        mc.globalPercent=0;

        function loadedComplete(Idx){

            console.log(arr[Idx].duration,Idx);

            // mc.globalPercent=arr[Idx].currentTime/arr[Idx].duration;
            // console.log(mc.globalPercent);
        }


        function initial() {
            for (var z = 0; z < getArr.length; z++) {
                arr.push(document.getElementById(getArr[z]))
                // arr[z].onload=loadedComplete(z);


                // arr[z].trigger("canplay",loadedComplete(z));
                // arr[z].addEventListener('timeupdate', function () {
                    // console.log(mc.globalPercent);
                    // mc.globalPercent=arr[z].currentTime/arr[z].duration;
                    // console.log(mc.globalPercent);
                // });
            }
        }
        initial();

        mc.zlmStop=function(){
            console.log(currentIdx);
            arr[currentIdx].pause();
            arr[currentIdx].currentTime=0.0;
        }
        mc.zlmPlay=function(Idx){


                arr[currentIdx].pause();

                    currentIdx=Idx;
                    arr[currentIdx].pause();
                    // arr[z].fastSeek(0);
                    // arr[z].seekable;


                    // arr[z].pause();
                    // arr[currentIdx].load();
                arr[currentIdx].play();







                    console.log("当前Idx:",currentIdx);



            console.log("歌曲时间总长:",arr[currentIdx].duration);
            // alert(arr[currentIdx].duration)
            var totalTime=arr[currentIdx].duration;

            var timeArr=[Math.floor(totalTime/60),Math.round(totalTime%60)]
            console.log(timeArr);
            return timeArr;
        }
        mc.zlmPause=function(){
            arr[currentIdx].pause();
        }
        mc.zlmResume=function(){
            arr[currentIdx].play();
        }
        mc.zlmSeek=function(getPercent){
            arr[currentIdx].currentTime=getPercent*arr[currentIdx].duration;
        }


        return mc;
    }
}
